package top.yaofengqiao.springcloudsimple.mybatisplus.starter.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.yaofengqiao.springcloudsimple.mybatisplus.starter.plugins.SlowSqlInnerInterceptor;

/**
 * @author yfq
 * @date 2024/6/18 15:04
 * @description
 */
@Configuration
public class SimpleMybatisPlusAutoConfiguration {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        // 分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));

        return interceptor;
    }

    /**
     * 慢sql插件
     */
    @Bean
    public Interceptor slowSqlInnerInterceptor() {
        return new SlowSqlInnerInterceptor();
    }

}
